package com.example.hospitalsystem.controller;

import com.example.hospitalsystem.pojo.dto.registration.AddRegistionDto;
import com.example.hospitalsystem.pojo.dto.registration.RegistrationListDto;
import com.example.hospitalsystem.pojo.dto.registration.RegistrationpageQueryDto;
import com.example.hospitalsystem.pojo.entity.Doctor;
import com.example.hospitalsystem.pojo.entity.Registration;
import com.example.hospitalsystem.pojo.vo.RegistrationInfoVO;
import com.example.hospitalsystem.result.Result;
import com.example.hospitalsystem.result.ResultCodeEnum;
import com.example.hospitalsystem.service.RegistrationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name="6.挂号表模块")
@RequestMapping("/registration")
public class RegistrationController {

    @Autowired
    private RegistrationService registrationService;

    @Operation(summary = "分页获取全部挂号信息", security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/getRegistrationInfoPage")
    public Result<Object> getRegistrationPage(@RequestBody RegistrationpageQueryDto registrationpageQueryDto){
        return registrationService.getRegistrationPage(registrationpageQueryDto);
    }

    @Operation(summary = "挂号预约", security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/addRegistrationInfo")
    public Result<Object> addRegistration(@RequestBody AddRegistionDto addRegistionDto){
        return registrationService.addRegistrationInfo(addRegistionDto);
    }

    @Operation(summary = "返回挂号列表", security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping("/registrationList")
    public Result<Object> registrationList(){
        List<Registration> list = registrationService.getRegistrationList();
        return Result.ok(list);
    }


    @Operation(summary = "批量删除挂号信息", security = {@SecurityRequirement(name = "Authorization")})
    @DeleteMapping
    public Result<Object> deleteBatchRegistration(@RequestParam List<Integer> ids){
        registrationService.deleteBatchRegistration(ids);
        return Result.ok(ResultCodeEnum.SUCCESS, "批量删除挂号信息成功");
    }

}
